package com.play.base_activity;

import android.content.Intent;
import android.view.View;

import androidx.fragment.app.FragmentTransaction;

import com.gyf.barlibrary.ImmersionBar;
import com.play.base_dialog.BaseDialogFragment;
import com.socks.library.KLog;


/**
 * Author by jmf,
 * Date on 2021/12/13.
 */
public abstract class BaseActivity extends BaseAbastractActivity {


    @Override
    protected void initView(View contentView) {

    }


    @Override
    protected ActivtyType getActivityType() {
        return null;
    }

    @Override
    protected void onResume() {
        super.onResume();
        KLog.e(this.getClass().getSimpleName());
    }


    /**
     * 解决软键盘与底部输入框冲突的问题
     *
     * @param view
     */
    public void initTopBar(View view) {
        ImmersionBar.with(this).statusBarView(view)
                .keyboardEnable(true)
                .statusBarDarkFont(true, 0.2f)
                .init();
    }

    @Override
    protected void onPause() {
        super.onPause();
        KLog.e(this.getClass().getSimpleName());
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        KLog.e(this.getClass().getSimpleName());
        ActivitiesManager.removeActivty(this);
    }


    @Override
    public void finish() {
        super.finish();
        KLog.e(this.getClass().getSimpleName());
    }


    /**
     * ImmersionBar 自动填充状态栏高度
     *
     * @param viewId
     */
    public void statusBarView(int viewId) {
        ImmersionBar.with(this).statusBarView(findViewById(viewId)).init();
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        /**
         *    在这可以统一处理普遍的 事件操作
         *    如 截获 截图请求， 全局 播放等
         */

    }

    public void showQuickFrgmtDlg(BaseDialogFragment frgmt) {
        if (frgmt == null) {
            return;
        }
        try {
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            if (!frgmt.isAdded()) {
                frgmt.show(ft, "dialogQuick");
                getSupportFragmentManager().executePendingTransactions();
            }
//            frgmt.show(ft, "dialog");
        } catch (Exception ex) {
        }
    }

}
